<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="../session.jsp"%>
<!DOCTYPE html>
<html lang="ko">
  <head>
  	<%@ include file="../head.jsp"%>
  	<script src="resources/js/jquery.js"></script>
	<script src="resources/js/bootstrap.min.js"></script>
  </head>
  <body>
  	<%@ include file="../menu.jsp"%>
	<div class="container">
		<div class="page-header">
			<h2>관리자 계정추가 - <small>새로운 계정을 추가하세요.</small></h2>
		</div>

		<form id="addAdmin" class="form-horizontal" role="form" method="post" action="addAdminOk">
			<fieldset>
				<div class="form-group">
					<label for="nickName" class="col-md-2 control-label">닉네임</label>
					<div class="col-md-10">
						<input type="text" class="form-control" name="nickName" placeholder="닉네임을 입력하세요" autofocus/>
					</div>
				</div>

				<div class="form-group">
					<label for="adminId" class="col-md-2 control-label">아이디</label>
					<div class="col-md-10">
						<input type="text" class="form-control" name="adminId" placeholder="아이디를 입력하세요"/>
					</div>
				</div>
				
				<div class="form-group">
					<label for="passWord1" class="col-md-2 control-label">비밀번호</label>
					<div class="col-md-10">
						<input type="password" class="form-control" name="passWord1" placeholder="비밀번호를 입력하세요"/>
					</div>
				</div>
				
				<div class="form-group">
					<label for="passWord2" class="col-md-2 control-label">비밀번호 확인</label>
					<div class="col-md-10">
						<input type="password" class="form-control" name="passWord2" placeholder="비밀번호를 한번더 입력하세요"/>
					</div>
				</div>

				<div class="form-group">
					<label for="adminLevel" class="col-md-2 control-label">등급</label>
					<div class="col-md-10">
						<select name="adminLevel" class="form-control">
							<option>- 선택하세요 -</option>
							<option value="1">1등급</option>
							<option value="2">2등급</option>
							<option value="3">3등급</option>
							<option value="4">4등급</option>
							<option value="5">5등급</option>
						</select>
					</div>
				</div>

				<div class="form-group">
					<div class="col-md-offset-2 col-md-10">
						<div class="row">
							<div class="col-md-6">
								<button type="submit" class="btn btn-primary btn-block">저장하기</button>
							</div>
							<div class="col-md-6">
								<button type="reset" class="btn btn-warning btn-block">다시작성</button>
							</div>
						</div>

					</div>
				</div>
			</fieldset>
		</form>
	</div>
	
	<!-- 형식검사 클래스 참조 -->
	<script src="resources/js/string.js"></script>
	<script type="text/javascript">
		$(function() {
			$("#addAdmin").submit(function() {
				
				if (!$("input[name='nickName']").val().isValue()) {
					alert("닉네임을 입력하세요.");
					$("input[name='nickName']").focus();
					return false;
				}
				
				if (!$("input[name='adminId']").val().isValue()) {
					alert("아이디를 입력하세요.");
					$("input[name='adminId']").focus();
					return false;
				}
				
				if (!$("input[name='passWord1']").val().isValue()) {
					alert("비밀번호를 입력하세요.");
					$("input[name='passWord1']").focus();
					return false;
				}
				
				if (!$("input[name='passWord2']").val().isValue()) {
					alert("비밀번호 확인을 입력하세요.");
					$("input[name='passWord2']").focus();
					return false;
				}
				
				if ($("input[name='passWord1']").val() != $("input[name='passWord2']").val()) {
					alert("비밀번호는 동일하게 입력해야 합니다.");
					$("input[name='passWord2']").focus();
					return false;
				}
				
				if ($("select[name='adminLevel'] > option:selected").index() < 1) {
					alert("등급을 선택하세요.");
					$("select[name='adminLevel']").focus();
					return false;
				}
				
				if (!confirm("정말 등록 하시겠습니까?")) {
					return false;
				}
			});
		});
	</script>
  </body>
</html>